<?php
/**
 * Joomla! 1.5 component JoomGPSTracks
 *
 * @version $Id: joomgpstracks.php 2009-06-24 15:40:19 svn $
 * @author Michael Pfister
 * @package joomGPStracks
 * @subpackage frontend
 * @license GNU/GPL
 * @filesource
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');


// Require the base controller
require_once JPATH_COMPONENT.DS.'controller.php';

// Require the base helper
require_once JPATH_COMPONENT.DS.'helpers'.DS.'layout.php';
require_once JPATH_COMPONENT.DS.'helpers'.DS.'helper.php';
JLoader::register('gpsCLass', './components/com_joomgpstracks/helpers/');
JLoader::import('components.com_joomgpstracks.helpers.gpsClass', JPATH_SITE, 'gpsClass');

$cfg = joomgpstracksHelper::getConfig();
// set the template
$tmpl = ($cfg->template = "") ? $cfg->template : 'default';

$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::base().'components/com_joomgpstracks/assets/gpstracks.css');
$document->addStyleSheet(JURI::base().'components/com_joomgpstracks/assets/template/'.$tmpl.'/style.css');



// Initialize the controller
if($controller = JRequest::getWord('controller')) {
    $path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
    if (file_exists($path)) {
        require_once $path;
    } else {
        $controller = '';
    }
}

$classname    = 'JoomgpstracksController'.ucfirst($controller);
$controller   = new $classname( );

// Register Extra tasks
$controller->registerTask( 'save', 'save' );

$controller->execute( JRequest::getCmd( 'task' ) );

// Redirect if set by the controller
$controller->redirect();
?>